package ro.isdc.training.jpa.test.systemuser.dao;

import java.util.List;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import ro.isdc.training.jpa.systemuser.dao.SystemUserDAO;
import ro.isdc.training.jpa.systemuser.domain.SystemUser;

/**
 * Simple class to demonstrate Spring + JPA
 * 
 * @author Andrei Chirila
 */
public class StandaloneClient {
  public static void main(String[] args) {

    ApplicationContext context = new ClassPathXmlApplicationContext(
        new String[] { 
            "classpath:common-applicationContext.xml",
            "classpath:dao-applicationContext.xml",
            "classpath:dataSource-applicationContext.xml" });
    
    SystemUserDAO systemUserDAO = (SystemUserDAO) context.getBean("systemUserDAO");
    List<SystemUser> systemUsers = systemUserDAO.findSystemUsers();
    for(SystemUser systemUser : systemUsers) {
      System.out.println("System user: " + systemUser);
    }
  }
}
